//
//  StoreDetailBusinessNewsCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/2.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "StoreDetailBusinessNewsCell.h"

@implementation StoreDetailBusinessNewsCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)fillCellWithModel:(CommonDynamicModel*)model {
    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.imageUrls.firstObject.url] placeholderImage:[UIImage imageNamed:@"placeholder"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        if (image) {
         
            if (cacheType != SDImageCacheTypeMemory) {
                [UIView transitionWithView:self.mainImageView duration:0.61 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
                    [self.mainImageView setImage:image];
                    self.mainImageView.alpha = 1.0;
                } completion:nil];
            } else {
                self.mainImageView.alpha = 1.0;
                [self.mainImageView setImage:image];
            }
        }
    }];
    
    if (model.sdyTitle.length > 0) {
        self.mainTitle.text = model.sdyTitle;
    } else {
        self.mainTitle.text = @"未获取到标题";
    }
    
    if (model.day.length > 0) {
        if ([model.day isEqualToString:@"今天"]) {
            self.dayLab.text = [NSString stringWithFormat:@"%@",model.day];
        } else {
            self.dayLab.text = [NSString stringWithFormat:@"%@日",model.day];
        }
    } else {
        self.monthLab.text = @"";
    }

    if (model.month.length > 0) {
        self.monthLab.text = [NSString stringWithFormat:@"%@月",model.month];
    } else {
        self.monthLab.text = @"";
    }
    
}

+ (CGFloat)calculateHeight {

    return 300;
}

@end
